package com.gandong8.derby.listenter;

import com.gandong8.derby.service.WebSiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class CreateTableListener implements ApplicationListener<ApplicationReadyEvent> {

    @Autowired
    private WebSiteService webSiteService;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        initCreateTable();
    }

    private void initCreateTable(){
        webSiteService.createTableIfNotExist();
    }

}
